/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package Model;

import java.io.Serializable;
import javax.persistence.*;
import javax.xml.bind.annotation.XmlRootElement;

/**
 *
 * @author Sik
 */
@Entity
@Table(name = "disponibilite")
@XmlRootElement
@NamedQueries(
{
    @NamedQuery(name = "Disponibilite.findAll", query = "SELECT d FROM Disponibilite d"),
    @NamedQuery(name = "Disponibilite.findByDisponible", query = "SELECT d FROM Disponibilite d WHERE d.disponible = :disponible"),
    @NamedQuery(name = "Disponibilite.findByIdCompetition", query = "SELECT d FROM Disponibilite d WHERE d.disponibilitePK.idCompetition = :idCompetition"),
    @NamedQuery(name = "Disponibilite.findByIdAdherent", query = "SELECT d FROM Disponibilite d WHERE d.disponibilitePK.idAdherent = :idAdherent")
})
public class Disponibilite implements Serializable
{
    private static final long serialVersionUID = 1L;
    @EmbeddedId
    protected DisponibilitePK disponibilitePK;
    @Column(name = "disponible")
    private Boolean disponible;
    @JoinColumn(name = "idCompetition", referencedColumnName = "idCompetition", insertable = false, updatable = false)
    @ManyToOne(optional = false)
    private Competition competition;
    @JoinColumn(name = "idAdherent", referencedColumnName = "idAdherent", insertable = false, updatable = false)
    @ManyToOne(optional = false)
    private Adherent adherent;

    public Disponibilite()
    {
    }

    public Disponibilite(DisponibilitePK disponibilitePK)
    {
        this.disponibilitePK = disponibilitePK;
    }

    public Disponibilite(int idCompetition, int idAdherent)
    {
        this.disponibilitePK = new DisponibilitePK(idCompetition, idAdherent);
    }

    public DisponibilitePK getDisponibilitePK()
    {
        return disponibilitePK;
    }

    public void setDisponibilitePK(DisponibilitePK disponibilitePK)
    {
        this.disponibilitePK = disponibilitePK;
    }

    public Boolean getDisponible()
    {
        return disponible;
    }

    public void setDisponible(Boolean disponible)
    {
        this.disponible = disponible;
    }

    public Competition getCompetition()
    {
        return competition;
    }

    public void setCompetition(Competition competition)
    {
        this.competition = competition;
    }

    public Adherent getAdherent()
    {
        return adherent;
    }

    public void setAdherent(Adherent adherent)
    {
        this.adherent = adherent;
    }

    @Override
    public int hashCode()
    {
        int hash = 0;
        hash += (disponibilitePK != null ? disponibilitePK.hashCode() : 0);
        return hash;
    }

    @Override
    public boolean equals(Object object)
    {
        // TODO: Warning - this method won't work in the case the id fields are not set
        if (!(object instanceof Disponibilite))
        {
            return false;
        }
        Disponibilite other = (Disponibilite) object;
        if ((this.disponibilitePK == null && other.disponibilitePK != null) || (this.disponibilitePK != null && !this.disponibilitePK.equals(other.disponibilitePK)))
        {
            return false;
        }
        return true;
    }

    @Override
    public String toString()
    {
        return "Model.Disponibilite[ disponibilitePK=" + disponibilitePK + " ]";
    }
    
}
